#include<bits/stdc++.h>
using namespace std;

int a[20005];

signed main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    sort(a + 1, a + n + 1);

    int cnt1, cnt2;
    cnt1 = cnt2 = 1;

    for(int i = 2; i <= n; i++) {
        if(a[i] == a[i - 1])
            cnt1++;
        else
            break;
    }

    for(int i = n - 1; i >= 1; i--) {
        if(a[i] == a[i + 1])
            cnt2++;
        else
            break;
    }

    cout << a[1] << " " << cnt1 << "\n" << a[n] << " " << cnt2;
    return 0;
}

